package com.yzg.simple.netty.officialchat.server;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

/**
 * @author misterWei
 * @mailbox mynameisweiyan@gmail.com
 */
public class NettyOfficialTcpServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //这是Netty 提供的编码器
        pipeline.addLast("encode",new StringEncoder());
        //这是Netty 提供的解码器
        pipeline.addLast("decode",new StringDecoder());
        pipeline.addLast(new NettyOfficialTcpServerHandler());

    }
}
